<?php
/**
 * Created by PhpStorm.
 * User: Fight.节奏
 * Date: 2016/8/23
 * Time: 16:29
 */
//        公共头部菜单
//        1、获取头部分类名称
$cateModel=new Common\Model\Cate();
$topCate=$cateModel->where("pid=0")->get();
//(2)获取左侧菜单
       foreach($topCate as $k=>$u ){
           $topCate[$k]['son']=$cateModel->where("pid={$topCate[$k]['cid']}")->get();
       }
//        (3)获取左侧品牌分类
$brandModel=new \Common\Model\Brand();
$brandData=$brandModel->join('commodity cd','bid','=','cd.shop_brand_bid')->orderBy('bsort','desc')->groupBy('bid')->limit(8)->get();
//        (4)获取左侧热销商品分类
$commodityModel=new \Common\Model\Commod();
$commodData=$commodityModel->orderBy('coclick','desc')->limit(8)->get();
//        (5)搜索框下热门搜索
$hotsouData=$commodityModel->orderBy('coclick','desc')->limit(4)->get();
//p($_SESSION);
?>
<!--网页头部、包含灰条、搜索区、导航栏-->
<header>
    <!--灰色条形区域-->
    <div id="top_bar">
        <div class="top_center">
            <!--灰条左侧-->
            <!--可以在这打印_SESSION看-->
            <?php if(!isset($_SESSION['userinfo']['username'])):?>
                <div class="fl top_site">
<!--                    <a href="javascript:;">收货地</a>-->
                </div>
                <div class="fl top_user">
                    <a href="<?php echo U('User/index')?>">[登陆]</a>
                    <span>|</span>
                    <a href="<?php echo U('User/reg')?>">[注册]</a>
                </div>
            <?php else:?>
                <div class="fl top_site">
<!--                    <a href="javascript:;">收货地 &nbsp;&nbsp;</a>-->
                </div>
                <div class="fl top_site" >
                    欢迎<a target="_blank" style="color: red" href="p_<?php echo $_SESSION['userinfo']['uid']?>.html" id="yonghudenglu"><?php echo $_SESSION['userinfo']['username']; ?></a>  !
                    &nbsp;&nbsp;|<a target="_blank" style="color: red" href="p_<?php echo $_SESSION['userinfo']['uid']?>.html">个人中心</a>&nbsp;&nbsp;&nbsp;|<a href="<?php echo U('User/out')?>">[退出]</a>
                </div>
            <?php endif?>
            <!--灰条右侧-->
            <div class="fr top_nav">
<!--                <a href="">我的订单</a>-->
            </div>
        </div>
    </div>
    <!--图片广告-->
    <a id="pic" target="_blank" href="d_<?php echo 53?>_<?php echo 35?>.html"></a>
    <!--头部栏区域-->
    <div id="head_bar">
        <div class="h_center">
            <!--logo-->
            <div class="fl headbar_logo">
                <a href="index.html"><img src="./Public/Home/img/icon11.png"/></a>
            </div>
            <div class="fl headbar_slogan">
                <a href="javascript:;" style="cursor: default"><img src="./Public/Home/img/icon13.png"></a>
            </div>
            <!--中部搜索-->
            <div class="fl headbar_search">
                <div class="search_box">
                    <form action="<?php echo U('Price/index')?>" method="post">
                        <input type="text" name="search" id="" class="fl search_input" value="" />
                        <input type="submit" class="fl search_btn" value="搜索"/>
                    </form>
                </div>
                <div class="search_words">
                    <span>热门搜索:</span>
                    <?php foreach ($hotsouData as $u){?>
                    <a target="_blank" href="d_<?php echo $u['coid']?>_<?php echo $u['shop_category_cid']?>.html" class="link"><?php echo $u['coname']?></a>
                    <?php }?>
                </div>
            </div>
            <!--购物车-->
            <div class="fr buy_car_box">
                <div class="my_car">
                    <span class="silder"><?php if(isset($_SESSION['cart']['total_rows'])){?>
                <b><?php echo $_SESSION['cart']['total_rows']?></b><?php }else{?><b>0</b>
               <?php }?></span>
                    <a href="cart.html">我的购物车</a>
                </div>
                <?php if(!isset($_SESSION['cart'])|| $_SESSION['cart']['total_rows']==0){?>
                
<!--                <div class="car_empty">-->
<!--                    快去选择物品吧！-->
<!--                </div>-->
                <?php }else{?>
<!--                <div class="car_cont" id="cart_box">-->
<!--                    <h4>最近加入的商品</h4>-->
<!--                    <div class="shopProduct">-->
<!--                        <div class="new">-->
<!--                            <ul>-->
<!--                                <li class="clear">-->
<!--                                    <a href="" class="fl good_img"><img src="" alt="" width="50px" height="50px"></a>-->
<!--                                    <div class="fl goods_detail">-->
<!--                                        <a href="" class="fl goods_detail"></a>-->
<!--                                    </div>-->
<!--                                    <div class="fl goods_pri_box">-->
<!--                                        <span>￥<i>4324</i>X<b>1</b></span>-->
<!--                                        <a href="" class="delete_cart">删除</a>-->
<!--                                    </div>-->
<!--                                </li>-->
<!--                                <li class="clear"></li>-->
<!--                            </ul>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="buycar_total">-->
<!--                        <div class="total_pri">-->
<!--                            共<span>5</span>件商品，共计￥<span>4343</span>-->
<!--                        </div>-->
<!--                        <a href="" class="pay_btn">去购物车结算</a>-->
<!--                    </div>-->
<!--                </div>-->
                
               <?php }?>
                <p style="color: #999; text-align: center;">累计陪伴84万+用户</p>
            </div>
        </div>
    </div>
    <!--头部栏区域结束-->
    <!--导航条区域开始-->
    <div id="nav_bar">
        <div class="nav_center">
            <ul class="navbar_list">
                <li class="item all">
                    <a href="javascript:;" class="link" style="cursor: default">全部商品分类</a>
                    <ul class="nav_list">
                        <li class="bar">
                            <p class="nav_title type1">价格分类</p>
                            <div class="nav_page">
                                <div class="nav_container">
                                    <p class="nav_name">价格选择</p>
                                    <ul class="nav_type">
                                        <li class="item"><a target="_blank" href="pr_<?php echo 1?>_<?php echo 499?>.html" class="link">1-499</a></li>
                                        <li class="item"><a target="_blank" href="pr_<?php echo 500?>_<?php echo 999?>.html" class="link">500-999</a></li>
                                        <li class="item"><a target="_blank" href="pr_<?php echo 1000?>_<?php echo 1999?>.html" class="link">1000-1999</a></li>
                                        <li class="item"><a target="_blank" href="pr_<?php echo 2000?>_<?php echo 2999?>.html" class="link">2000-2999</a></li>
                                        <li class="item"><a target="_blank" href="pr_<?php echo 3000?>_<?php echo 3999?>.html" class="link">3000-3999</a></li>
                                        <li class="item"><a target="_blank" href="pr_<?php echo 4000?>_<?php echo 4999?>.html" class="link">4000-4999</a></li>
                                        <li class="item"><a target="_blank" href="pr_<?php echo 5000?>_<?php echo 30000?>.html" class="link">5000以上</a></li>
                                    </ul>
                                    <a href="d_<?php echo 53?>_<?php echo 35?>.html" class="nav_img">
                                        <img src="./Public/Home/img/menua2.png" alt="" />
                                    </a>
                                </div>
                            </div>
                        </li>
                        <li class="bar">
                            <p class="nav_title type2">品牌分类</p>
                            <div class="nav_page">
                                <div class="nav_container">
                                    <p class="nav_name">品牌选择</p>
                                    <ul class="nav_type">
                                        <?php foreach ($brandData as $u){?>
                                        <li class="item"><a target="_blank" href="b_<?php echo $u['bid']?>.html" class="link"><?php echo $u['bname']?></a></li>
                                        <?php }?>
                                    </ul>
                                    <a href="d_<?php echo 54?>_<?php echo 35?>.html" class="nav_img">
                                        <img src="./Public/Home/img/menua7.png" alt="" />
                                    </a>
                                </div>
                            </div>
                        </li>
                        <li class="bar">
                            <p class="nav_title type6">热销商品</p>
                            <div class="nav_page">
                                <div class="nav_container">
                                    <p class="nav_name">热销商品</p>
                                    <ul class="nav_type">
                                        <?php foreach ($commodData as $u){?>
                                        <li class="item"><a target="_blank" href="d_<?php echo $u['coid']?>_<?php echo $u['shop_category_cid']?>.html" class="link"><?php echo $u['coname']?></a></li>
                                        <?php }?>
                                    </ul>
                                    <a href="d_<?php echo 55?>_<?php echo 35?>.html" class="nav_img">
                                        <img src="./Public/Home/img/menua3.png" alt="" />
                                    </a>
                                </div>
                            </div>
                        </li>
                        <?php foreach ($topCate as $k=>$u){?>
                        <li class="bar">
                            <p class="nav_title type<?php echo $k+4?>"><?php echo $u['cname']?></p>
                            <div class="nav_page">
                                <div class="nav_container">
                                    <p class="nav_name"><?php echo $u['cname']?></p>
                                    <ul class="nav_type">
                                        <?php foreach ($u['son'] as $v){?>
                                        <li class="item"><a target="_blank" href="c_<?php echo $v['cid']?>.html" class="link"><?php echo $v['cname']?></a></li>
                                        <?php }?>
                                    </ul>
                                    <a href="d_<?php echo 53+$k?>_<?php echo 35?>.html" class="nav_img">
                                        <img src="./Public/Home/img/menua<?php echo $k+4?>.png" alt="" />
                                    </a>
                                </div>
                            </div>
                        </li>
                        <?php }?>

                    </ul>
                </li>
                <?php foreach ($topCate as $u){?>
                <li class="item"><a href="c_<?php echo $u['cid']?>.html" <?php if(isset($_GET['cid'])&& $_GET['cid']==$u['cid']){?>
                class="on"
               <?php }?>><?php echo $u['cname']?></a></li>
                <?php }?>
            </ul>
        </div>
    </div>
    <!--导航条区域结束-->
</header>

